use arrow_flight::flight_service_server::FlightServiceServer;
use log::info;
use tonic::transport::Server;
use common::LResult;
use engine::DBRef;
use crate::server::SqlServerImpl;

mod server;
pub use server::*;
// mod flight_server;

pub async fn start_flight_sql_service(db: DBRef) -> LResult<()> {
    let svc = FlightServiceServer::new(SqlServerImpl::create(db));
    let addr = "127.0.0.1:8081".parse().unwrap();
    info!("Listening on: {:?}", addr);
    Server::builder().add_service(svc).serve(addr).await.unwrap();
    Ok(())
}